#
# Copyright 2009 Jeffrey Palm
#

require 'util'
require 'has_options'

# Parses arguments and launches the instance of CommonInterface by
# calling its run method.
class CommandLine

  attr_reader :common_interface
  attr_reader :parse_args

  def initialize(common_interface,parse_args)
    @common_interface = common_interface
    @parse_args       = parse_args
  end

  def real_main(argv)
    has_options = HasOptions.new
    ret = @parse_args.parse_args argv,has_options
    if ret == RET_PRINTED_HELP
      ret
    else
      @common_interface.run has_options
    end
  end

end
